// export default {
//   state: {
//     addProcessData: {},
//     addMaterialData: {},
//     updateNodeData: undefined,
//     deleteNodeData: undefined,
//     processNodeData: undefined, //  存放所有工序
//     graphData: undefined,
//     isAllowEdit: undefined, // 编码规则是否能编辑
//     isEnable: undefined, // 是否启用编码规则
//     showDetail: false// 是否为预览按钮进入
//   },
//   mutations: {
//     CHANGE_SETTING: (state, value) => {
//       state.updateNodeData = value
//     }
//   },
//   actions: {
//     changeSetting({ commit }, data) {
//       commit('CHANGE_SETTING', data)
//     }
//   }
// }

const state = {
  addProcessData: {},
  addMaterialData: {},
  updateNodeData: undefined,
  deleteNodeData: undefined,
  processNodeData: undefined, //  存放所有工序
  graphData: undefined,
  isAllowEdit: undefined, // 编码规则是否能编辑
  isEnable: undefined, // 是否启用编码规则
  showDetail: false// 是否为预览按钮进入
}

const mutations = {
  CHANGE_SETTING: (state, value) => {
    state.updateNodeData = value
  },
  CHANGE_DELETE: (state, value) => {
    state.deleteNodeData = value
  },
  CHANGE_DATA: (state, value) => {
    const obj = {
      addProcessData: {},
      addMaterialData: {},
      updateNodeData: undefined,
      deleteNodeData: undefined,
      processNodeData: undefined, //  存放所有工序
      graphData: undefined,
      isAllowEdit: undefined, // 编码规则是否能编辑
      isEnable: undefined, // 是否启用编码规则
      showDetail: false// 是否为预览按钮进入
    }
    Object.keys(state).forEach(key => {
      state[key] = obj[key]
    })
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
  changeData({ commit }, data) {
    commit('CHANGE_DATA', {})
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
